import { defineStore } from 'pinia'
import { getTodayNumber, getWeekNumber, getMonthNumber, getWeekTrend, getDistribution } from '@/service/main/statistics/statistics'
const useStatisticsStore = defineStore('statistics', {
	state: () => ({
		todayNumber: '',
		weekNumber: '',
		monthNumber: '',
		dateList: [],
		registerNumList: [],
		parkDistributionList: []
	}),
	actions: {
		async getTodayNumber() {
			const result = await getTodayNumber()
			this.todayNumber = result.data
		},
		async getWeekNumber() {
			const result = await getWeekNumber()
			this.weekNumber = result.data
		},
		async getMonthNumber() {
			const result = await getMonthNumber()
			this.monthNumber = result.data
		},
		async getWeekTrend() {
			const result = await getWeekTrend()
			// 将字符串转换为数组
			this.dateList = result.data.dateList.split(',') // 转换为学院名称数组
			this.registerNumList = result.data.registerNumList.split(',').map(Number) // 转换为数字数组

		},
		async getDistribution() {
			const result = await getDistribution()
			this.parkDistributionList = result.data
		}
	}
}
)
export default useStatisticsStore